﻿#ifndef PST_JSONPARSER_H
#define PST_JSONPARSER_H

#include "JsonDef.h"

#include <qobject.h>

namespace pst
{
    class JsonParser : public QObject
    {
    public:
        struct ProjectData {
            QVector<HearderFileInfo> projectFileData;
            QVector<ResultDataPointer> projectResultData;
        };
        using ProjectDataPointer = QSharedPointer<ProjectData>;
    
        struct ResultInfo {
            ProjectDataPointer projectData;
            QStringList errorMessageList;
        };
    
        static JsonParser* GetInstance();
        
        ResultInfo GetResultData(const QVector<QString>& filepathArray);
        
        ResultInfo GetProjectData(const QString& filePath);
        
        void GetHeardData(ResultInfo& resultInfo, HearderFileInfo& heardFileInfo);
        
        bool GetHeardUniqueData(ResultInfo& resultInfo, HearderFileData& hearderFileData, const QJsonObject& jsonObject);
        
        inline QList<ProjectDataPointer> GetProjectDataList() const{
            return m_projectDataList;
        }
        inline const QList<ProjectDataPointer>& GetCProjectDataList() const {
            return m_projectDataList;
        }
    
    private:
        explicit JsonParser(QObject* parent = nullptr);
        ~JsonParser();
        JsonParser(const JsonParser&) = delete;
        JsonParser& operator=(const JsonParser&) = delete;
        
        QList<ProjectDataPointer> m_projectDataList;
    };
}


#endif
